function t(t) {
    return t && t.__esModule ? t : {
        default: t
    };
}

var e = t(require("../../utils/user")), a = t(require("../../utils/util"));

Component({
    properties: {
        appName: {
            type: String,
            value: "card"
        },
        title: {
            type: String,
            value: "创建名片"
        },
        confirmText: {
            type: String,
            value: "完成"
        },
        form: {
            type: Object,
            value: {}
        },
        fields: {
            type: Array,
            value: [ [ "user", "corpname", "position" ] ]
        },
        validFilds: Array
    },
    data: {
        submitDisabled: !0,
        shown: !1
    },
    ready: function() {
        var t = this;
        if (this.createForm = this.selectComponent("#create-form"), !this.data.form.realname) {
            var i = function(e) {
                var i = e.avatar, r = e.realname;
                t.setData({
                    "form.avatar": i,
                    "form.realname": a.default.sliceByByte(a.default.filterEmoji(r), 8)
                });
            };
            e.default.getTokensSync().realname ? i(e.default.getTokensSync()) : e.default.listenToken(i);
        }
    },
    methods: {
        onConfirm: function(t) {
            var e = this.data.form;
            Object.assign(e, this.createForm.getFormData()), this.triggerEvent("submit", e, {});
        },
        onInput: function() {
            this.checkSubmitState();
        },
        onClear: function() {
            this.checkSubmitState();
        },
        checkSubmitState: function() {
            var t = this.createForm.getFormData();
            this.setData({
                submitDisabled: !t
            });
        },
        onCancel: function() {
            this.setData({
                shown: !1
            });
        },
        onShow: function() {
            this.setData({
                shown: !0
            });
        }
    }
});